-
Notifications
You must be signed in to change notification settings - Fork 990
Added support for the database engine plugin system for extending sqlc with new databases (in addition to PostgreSQL, Dolphin (MySQL), sqlite) #4247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
asmyasnikov
wants to merge
23
commits into
sqlc-dev:main
Choose a base branch
from
ydb-platform:engine-plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
asmyasnikov
commented
Dec 28, 2025
…c with new databases (in addition to PostgreSQL, Dolphin, sqlite)
fd040bc to
6c5b9a6
Compare
a5131b5 to
7609ebc
Compare
asmyasnikov
commented
Jan 27, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolve issue #4158
Database Engine Plugins
sqlc supports adding custom database backends through engine plugins. This allows you to use sqlc with databases that aren't natively supported (like YDB, Clickhouse, CockroachDB, or other SQL-compatible databases).
Overview
Engine plugins are external programs that implement the sqlc engine interface:
Compatibility Guarantee
For Go process plugins, compatibility is guaranteed at compile time:
When you import this package:
The Protocol Buffer schema ensures binary compatibility. No version negotiation needed.
Configuration
sqlc.yaml
Configuration Options
namesql[].engine)process.cmdwasm.urlfile://orhttps://)wasm.sha256envCreating a Go Engine Plugin
1. Import the SDK
2. Implement the Handler
3. Implement Methods
Parse
Parses SQL text into statements with AST.
GetCatalog
Returns the initial catalog with built-in types and functions.
IsReservedKeyword
Checks if a string is a reserved keyword.
GetCommentSyntax
Returns supported SQL comment syntax.
GetDialect
Returns SQL dialect information for formatting.
4. Build and Install
go build -o sqlc-engine-somedb . mv sqlc-engine-somedb /usr/local/bin/Protocol
Process Plugins (Go)
Process plugins use Protocol Buffers for serialization:
The proto schema is published at
buf.build/sqlc/sqlcinengine/engine.proto.Methods are invoked as command-line arguments:
WASM Plugins
WASM plugins use JSON for broader language compatibility:
Full Example
See
examples/plugin-based-codegen/for a complete engine plugin implementation.Architecture